﻿CREATE PROCEDURE [dbo].[message_update]
    @messageId int,
    @dateOfRead datetime=null,
    @dateOfSend datetime,
    @message nvarchar(max),
    @recipientId int ,
    @senderId int
AS
UPDATE [dbo].[Messages] SET 
    [dbo].[Messages].[DateOfRead] = @dateOfRead,
    [dbo].[Messages].[DateOfSend] = @dateOfSend,
    [dbo].[Messages].[Message] = @message,
    [dbo].[Messages].[RecipientId] = @recipientId,
    [dbo].[Messages].[SenderId] = @senderId
WHERE 
    [dbo].[Messages].[MessageId] = @messageId
SELECT 
    [MessageId],
    [DateOfRead],
    [DateOfSend],
    [Message],
    [RecipientId],
    [SenderId]
FROM 
    [dbo].[Messages]
WHERE
    [Messages].[MessageId] = @messageId
RETURN 0
